package com.tisson.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class SqlExecutor {
/*	private int resultCode=-654321;
	public int executeUpdate(String sqlStr){
		try {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
			String url = "jdbc:odbc:database";
			Connection con = DriverManager.getConnection(url, "sa", "dljk");
			Statement stmt = con.createStatement();
			resultCode = stmt.executeUpdate(sqlStr);
			stmt.close();
			con.close();
		}
		catch (Exception e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
		return resultCode;
	}
	
	public ResultSet executeQuery(String sqlStr){
		ResultSet rs = null;
		try {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
			String url = "jdbc:odbc:database";
			Connection con = DriverManager.getConnection(url, "sa", "dljk");
			Statement stmt = con.createStatement();
			rs = stmt.executeQuery(sqlStr);
			stmt.close();
			con.close();
		}
		catch (Exception e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
		return rs;
	}
	
	public Statement getStatement(){
		try {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
			String url = "jdbc:odbc:database";
			Connection con = DriverManager.getConnection(url, "sa", "dljk");
			return con.createStatement();
		}
		catch (Exception e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
			return null;
		}
	}*/
}
